package com.eva.admin.api.system;

import com.eva.framework.common.api.BaseController;
import com.eva.admin.biz.system.SystemJobLogBiz;
import com.eva.admin.dao.system.dto.QuerySystemJobLogDTO;
import com.eva.dao.system.model.SystemJobLog;
import com.eva.framework.common.model.ApiResponse;
import com.eva.framework.common.model.PageData;
import com.eva.framework.common.model.PageWrap;
import com.eva.framework.rbac.authorize.ContainPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "系统定时任务日志")
@RestController
@RequestMapping("/system/job/log")
public class SystemJobLogController extends BaseController {

    @Resource
    private SystemJobLogBiz systemJobLogBiz;

    @ApiOperation("删除")
    @GetMapping("/delete/{id}")
    @ContainPermissions("system:location:delete")
    public ApiResponse<?> deleteById(@PathVariable Integer id) {
        systemJobLogBiz.deleteById(id);
        return ApiResponse.success(null);
    }

    @ApiOperation("批量删除")
    @GetMapping("/delete/batch")
    @ContainPermissions("system:location:delete")
    public ApiResponse<?> deleteByIdInBatch(@RequestParam String ids) {
        systemJobLogBiz.deleteByIdInBatch(this.getIdList(ids));
        return ApiResponse.success(null);
    }

    @ApiOperation("分页查询")
    @PostMapping("/page")
    @ContainPermissions("system:job:log:query")
    public ApiResponse<PageData<SystemJobLog>> findPage (@RequestBody PageWrap<QuerySystemJobLogDTO> pageWrap) {
        return ApiResponse.success(systemJobLogBiz.findPage(pageWrap));
    }
}
